#include "stdafx.h"
#include "ToolbarOwnerWindow.h"

CToolbarOwnerWindow::CToolbarOwnerWindow()
{

}

CToolbarOwnerWindow::~CToolbarOwnerWindow()
{
    ReleaseResources();
}

CToolbarWindow& CToolbarOwnerWindow::GetToolbarWnd()
{
    return m_toolbarWnd;
}

LRESULT CToolbarOwnerWindow::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    RECT windowRect = {0};
    GetClientRect(&windowRect);
    
    DWORD toolbarStyle = WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_TABSTOP 
                             | CCS_NORESIZE | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_TOP
                             | TBSTYLE_LIST | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS;
                            

    LPCREATESTRUCT lpCreateStruct = LPCREATESTRUCT(lParam);	
    if (m_toolbarWnd.Create(m_hWnd, windowRect, L"IEToolbar", toolbarStyle, 0, 0, lpCreateStruct->lpCreateParams) == NULL)
        return -1;

    return 0;
}

void CToolbarOwnerWindow::ReleaseResources()
{
    if (IsWindow())
    {
        DestroyWindow();
    }
}